package com.cgx.controller;

import com.cgx.annotation.ResultHandler;
import com.cgx.service.FriendService;
import com.cgx.vo.RequestObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author chenguanxin
 * @date 2021-05-26 22:52
 */
@Controller
@CrossOrigin("*")
@RequestMapping("/api/friend")
public class FriendApiController {

    @Autowired
    private FriendService friendService;

    @ResponseBody
    @ResultHandler
    @RequestMapping("/addFriend")
    public Object addFriend(@RequestBody RequestObject requestObject) {
        return friendService.addFriend(requestObject.getData());
    }

    @ResponseBody
    @ResultHandler
    @RequestMapping("/queryBySearchText")
    public Object queryBySearchText(@RequestBody RequestObject requestObject) {
        return friendService.queryBySearchText(requestObject.getData());
    }
}
